package mobi.greenplate.theweb.converter;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import mobi.greenplate.theweb.domain.Friend;


@XmlRootElement(name="friend-list")
public class FriendListConverter {

    private final List<Friend> entities;

    public FriendListConverter() {
        this.entities=new ArrayList<Friend>();
    }
    
    public FriendListConverter(List<Friend> entities) {
        this.entities = entities;
    }

    @XmlElement
    public List<FriendConverter> getFriend(){
        final List<FriendConverter> list = new ArrayList<FriendConverter>();
        for (Friend friend : entities) {
            list.add(new FriendConverter(friend));
        }
        return list;
    }

    @XmlTransient
    public List<Friend> getEntities(){
        return Collections.unmodifiableList(this.entities);
    }

}


